import { fileURLToPath, URL } from 'node:url'
const baseUrl = '/'
export default defineNuxtConfig({
  app: {
    baseURL:"/",
    //  baseURL: '/prefix/'
    // layoutTransition: { name: 'layout', mode: 'out-in' },
    // pageTransition: { name: "page", mode: "out-in" },
    head: {
      title: "Nuxt3",
      meta: [
        { name: "viewport", content: "width=device-width, initial-scale=1" },
        {
          name: "description",
          content: "Nuxt3",
        },
      ],
      link: [
        {
          rel: "stylesheet",
          href: "/css/swiper.css",
        },
      ],
      script: [
        // {
        //   src: "/js/swiper.js",
        //   type: "text/javascript",
        // },
        {
          src: `${baseUrl}js/browser_jianrong.js`,
          type: "text/javascript",
        },
        {
          src: `${baseUrl}js/rem.js`,
          type: "text/javascript",
        },
        {
          src: `${baseUrl}js/counter.js`,
          type: "text/javascript",
        },
        // {
        //   src: "https://api.map.baidu.com/api?v=2.0&type=webgl&ak=2b866a6daac9014292432d81fe9b47e3",
        //   type: "text/javascript",
        // },
      ],
    },
  },
  
  runtimeConfig: {
    apiSecret: import.meta.env.NUXT_API_SECRET as string, // can be overridden by NUXT_API_SECRET environment variable
    public: {
      apiBase: import.meta.env.NUXT_PUBLIC_API_BASE as string, // can be overridden by NUXT_PUBLIC_API_BASE environment variable
    },
  },

  devServer: {
    port: 3009,
    host: "0.0.0.0",
  },

  nitro: {
    prerender: {
      // crawlLinks: false,
      // routes: ["/sitemap.xml", "/sitemap.txt", "/sitemap.htm"],
    },
  },

  postcss: {
    plugins: {
      tailwindcss: {},
      autoprefixer: {
        overrideBrowserslist: [
          "Android 4.1",
          "iOS 8.0",
          "Chrome > 67",
          "ff > 31",
          "ie >= 10",
          "last 10 versions", // 所有主流浏览器最近10版本用
        ],
        grid: false,
      },
    },
  },
  css: [
    // "@/assets/styles/main.css",
    "animate.css/animate.compat.css",
  ],

  vue: {
    compilerOptions: {
      isCustomElement: (tag) => tag.startsWith("swiper-"),
    },
  },

  build: {
    analyze: false,
  },

  sourcemap: {
    // server: false,
  },

  appConfig: {
    nuxt: {
      buildId: '1',
    },
  },
 
  vite: {
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./', import.meta.url))
      },
    },
    build: {
      terserOptions: {
        compress: {
          drop_console: true,
          keep_infinity: true,
        },
      },

      rollupOptions: {
        output: {
          entryFileNames: "_nuxt/[name].js",
          // chunkFileNames: '_nuxt/chunks/[name]-[hash].js',
          // entryFileNames: '_nuxt/js/[name]-[hash].js',
          // assetFileNames: '_nuxt/[name]-[hash].[ext]'
          // entryFileNames: "_nuxt/[name].js",
        },
      },
      minify: "terser",
      target: ["chrome60", "es2015"],
      // target: "es2015",
      commonjsOptions: {
        include: ["./node_modules/**"],
        transformMixedEsModules: true,
      },
    },
    plugins: [
      // createSvgIconsPlugin({
      //   iconDirs: [path.resolve(process.cwd(), "assets/svg")],
      // }),
    ],
    css: {
      preprocessorOptions: {
        scss: {
          quietDeps: true,
          api: "modern",
          additionalData: '@forward "@/assets/styles/index.scss";',
        },
      },
    },
  },

  modules: ["@nuxt/image",'@vueuse/motion/nuxt'],
  compatibilityDate: "2024-12-24",
});